/**
 * 试管架
 */
Cotton18 = Widget.extend({
	runningAction:null,
	runningAction1:null,
	ctor:function(parent){
		this._super();
		parent.addChild(this,29);
		this.setTag(TAG_COTTON);
		this.init();
	},
	init : function(){
		this.setVisible(false);
		this.setCascadeOpacityEnabled(true);

		var cotton=new Button(this,10,TAG_COTTON1,"#run/Cotton.png",this.callback);
		cotton.setPosition(cc.p(900, 200));
		
		var spark=new Button(this,10,TAG_SPARK,"#run/spark.png",this.callback);
		spark.setPosition(cc.p(600, 220));
		spark.setOpacity(0);
		
		var cotton1=new Button(this,10,TAG_COTTON2,"#run/Cotton1.png",this.callback);
		cotton1.setPosition(cc.p(600, 220));
		cotton1.setOpacity(0);
	},
	fadeinSpark:function(){
		var fadein=cc.fadeIn(0.1);
		var spark=this.getChildByTag(TAG_SPARK);
		spark.runAction(fadein);
	},
	fadeoutSpark:function(){
		var fadeout=cc.fadeOut(0.3);
		var spark=this.getChildByTag(TAG_SPARK);
		spark.runAction(fadeout);
	},
	fadeinCotton1:function(){
		var fadein=cc.fadeIn(0.3);
		var cotton1=this.getChildByTag(TAG_COTTON2);
		cotton1.runAction(fadein);
	},
	fadeoutCotton:function(){
		var fadeout=cc.fadeOut(0.1);
		var cotton=this.getChildByTag(TAG_COTTON1);
		cotton.runAction(fadeout);
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		}, this);
		switch (p.getTag()) {
		case TAG_COTTON1:
			var ber=cc.bezierBy(1, [cc.p(-50,450),cc.p(-260,280),cc.p(-303,280)]);
			var move=cc.moveBy(2,cc.p(0, -256));
			p.runAction(cc.sequence(ber,move,func));
			break;
		default:
			break;
		}
	}
});
